package com.xujicheng.algorithm.sort;

import java.util.Arrays;
import java.util.Collection;

public abstract class BaseSort<T extends Comparable> implements Sort<T>{
    @Override
    public Collection sort(Collection<T> t, SortType sortType) {
        Object[] objects = t.toArray();
        switch (sortType){
            case ASC: sortAsc(objects);break;
            case DESC: sortDesc(objects);break;
            default: sortAsc(objects);break;
        }
        return Arrays.asList(objects);
    }

    protected abstract void sortDesc(Object[] objects);

    protected abstract void sortAsc(Object[] objects);
}
